package com.lcc.generate;

/**
 * @author lcc
 * @date 2025/1/13 16:03
 */
import com.lcc.generate.clazz.ClassUtils;
import com.lcc.generate.jsp.JspUtil;
import com.lcc.generate.mapper.MapperUtilsPG;
import com.lcc.generate.util.DruidPool;
import com.lcc.generate.util.MyField;
import com.lcc.generate.vue3.Vue3Util;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import java.sql.SQLException;
import java.util.List;

@Mojo(name = "generate-code")
public class GenerateCodeMojo extends AbstractMojo {

    @Parameter(property = "model", defaultValue = "")
    private String model;


    @Override
    public void execute() {
        Config config = Config.getConfig(model);
        DruidPool.init(config);
        List<List<MyField>> lists = null;
        try {
            lists = ClassUtils.generate(config);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        MapperUtilsPG.generate(lists, config);
        Vue3Util.generate(lists, config);
        JspUtil.generate(lists, config);
    }
}